package xyz.robinbingo.pfboot.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import xyz.robinbingo.pfboot.entity.User;
import xyz.robinbingo.pfboot.repository.UserRepository;
import xyz.robinbingo.pfboot.util.FaceUtils;

import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Named;

/**
 * UserController
 *
 * @author Robin
 * @date 2018/10/24 18:38
 **/
@Named
@ViewScoped
public class UserController {

    @Autowired
    private UserRepository userRepository;

    private User user;

    @PostConstruct
    public void init() {
        String username = FaceUtils.getRequest().getRemoteUser();
        user = userRepository.findByUsername(username);
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}
